import Cookies from 'js-cookie'

const initstate = {
  token: Cookies.get('token'),
  role: Cookies.get('role'), // 大区经理1 销售2  医生3
  userId: Cookies.get('userId'),
  pwd:  Cookies.get('pwd'),
};

const userReducer = (state = initstate, action) => {
  switch (action.type) {
    case 'LOGIN':
      return {
        ...state,
       ...action.data
      }
    case 'LOGOUT':
      return {
        token:null,
        role:null,
        userId:null,
        pwd:null
      }
    default:
      return state;
  }

}

export default userReducer;